# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=usbredir
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.8.0
pkgrel=1
arch=('any')
pkgdesc="Parser for the usbredir protocol (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libusb")
options=('strip' 'staticlibs')
license=("GPL 2")
url="https://www.spice-space.org/"
source=(https://www.spice-space.org/download/usbredir/${_realname}-${pkgver}.tar.bz2)
sha256sums=('87bc9c5a81c982517a1bec70dc8d22e15ae197847643d58f20c0ced3c38c5e00')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
}

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LIB"
}
